using LastFmLib.API20.Types;
using StaffWarsFm.Lib.Data;

namespace StaffWarsFm.Questions
{
    public class ArtworkQuestionService : QuestionServiceBase
    {
        private AlbumQuestionService _albumQuestionService = new AlbumQuestionService();

        [Question]
        public Question GetAlbumArtworkQuestion(ArtistInfo artist)
        {
            var album = _albumQuestionService.GetRandomAlbum(artist);

            return new Question
            {
                ImageUrl = artist.GetLargestImageUrl().ToString(),
                Text = string.Format("Which album was recorded by {0}?", artist.Name),
                Answers = GetAnswers(
                    album,
                    a => new Answer 
                    {
                        Text = a.Default(r => r.GetLargestImageUrl().ToString(), ""),
                        ImageUrl = a.Default(r => r.GetLargestImageUrl().ToString(), "")
                    }
                )
            };
        }

        [Question]
        public Question GetArtistArtworkQuestion(ArtistInfo artist)
        {
            return new Question
            {
                ImageUrl = "",
                Text = string.Format("Which of these photos is {0}?", artist.Name),
                Answers = GetAnswers(
                    artist,
                    a => new Answer
                    {
                        Text = a.Default(r => r.GetLargestImageUrl().ToString(), ""),
                        ImageUrl = a.Default(r => r.GetLargestImageUrl().ToString(), "")
                    }
                )
            };
        }
    }
}